# Maintainer: justforlxz <justforlxz@gmail.com>
pkgname=startdde-git
pkgver=5.9.15.1.r24.g9684bb4
pkgrel=1
sourcename=startdde
sourcetars=("$sourcename"_"$pkgver".tar.xz vendor.tar.gz)
sourcedir="$sourcename"
useforobs=1
pkgdesc="starter of deepin desktop environment"
arch=('x86_64' 'aarch64')
url="https://github.com/linuxdeepin/startdde"
license=('GPL3')
depends=('libgnome-keyring')
makedepends=('cmake' 'coffeescript' 'deepin-api-git' 'go' 'git' 'jq')
optdepends=('deepin-wm: Legacy 3D window manager'
            'deepin-metacity: Legacy 2D window manager'
            'deepin-kwin: Preferred window manager')
provides=('startdde')
conflicts=('startdde')
groups=('deepin-git')
source=("${sourcetars[@]}")
sha512sums=('SKIP' 'SKIP')

prepare() {
  cd $sourcedir
  export GOPATH="$srcdir/build:/usr/share/gocode"
  sed -i 's/sbin/bin/' Makefile
}

build() {
  if [[ ! -n "$useforobs" ]];then
    export GOFLAGS="-buildmode=pie -trimpath -modcacherw -mod=readonly"
    go mod tidy
  else
    export GOFLAGS="-buildmode=pie -trimpath -modcacherw -mod=vendor"
    mv "$srcdir"/vendor "$srcdir"/"$sourcedir"/vendor
  fi
  cd $sourcedir
  make
}

package() {
  cd $sourcedir
  make DESTDIR="$pkgdir" install
}
